<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>登录后台|{:config('app_name')}</title>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css">
    <link rel="stylesheet" href="__PUBLIC__/css/style.css">
</head>

<body>
    <div class="login layui-anim-up">
        <div class="login-main">
            <div class="login-box login-header">
                <h2>{:config('app_name')}</h2>
                <p>App后台管理系统</p>
            </div>
            <div class="login-box login-body layui-form">
                <div class="layui-form-item">
                    <label class="login-icon layui-icon layui-icon-username" for="username"></label>
                    <input type="text" name="username" id="username" lay-verify="required" placeholder="用户名" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="login-icon layui-icon layui-icon-password" for="password"></label>
                    <input type="password" name="password" id="password" lay-verify="required" placeholder="密码" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <div class="layui-row">
                        <div class="layui-col-xs7">
                            <label class="login-icon layui-icon layui-icon-vercode" for="captcha"></label>
                            <input type="text" name="captcha" id="captcha" lay-verify="required" placeholder="图形验证码" class="layui-input">
                        </div>
                        <div class="layui-col-xs5">
                            <div style="margin-left: 10px;">
                                <img src="{:captcha_src()}" class="login-codeimg" id="vercode">
                            </div>
                        </div>
                    </div>
                </div>
                <hr>
                <!-- <div class="layui-form-item" style="margin-bottom: 20px;">
                    <input type="checkbox" name="remember" value="1" lay-skin="primary" title="记住密码">
                </div> -->
                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="login">登 入</button>
                </div>
            </div>
        </div>
        <div class="login-footer">
            <hr>
            <p><span>Copyright©2014-{:date('Y')} by Leacmf < lea21st@qq.com ></span></p>
        </div>
    </div>
    <script src="__PUBLIC__/js/jquery.min.js"></script>
    <script src="__PUBLIC__/layui/layui.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
        $('#vercode').click(function() {
            var src = '{:captcha_src()}';
            $(this).attr('src', src + '?' + Math.random());
        });
    });
    layui.use(['form', 'layer'], function() {
        var layer = layui.layer;
        layui.form.on('submit(login)', function(data) {
            var self = $(data.elem);
            if (self.attr('disabled')) {
                return false;
            }
            self.attr('disabled', 'disabled');
            $.ajax({
                    url: data.action || '',
                    type: 'POST',
                    dataType: 'json',
                    data: data.field
                })
                .done(function(res) {
                    if (res.code == 1) {
                        layer.msg(res.msg, {
                            time: 1000,
                            icon: 6
                        }, function() {
                            console.log(res.url);
                            window.location.href = res.url
                        });
                    } else {
                        layer.msg(res.msg, {
                            time: 1500,
                            icon: 5
                        });
                    }
                })
                .fail(function() {
                    layer.msg('服务器异常', {
                        time: 1500,
                        icon: 5
                    });
                })
                .always(function() {
                    $('#vercode').click();
                    self.removeAttr('disabled');
                });
            return false;
        });
    });
    </script>
</body>

</html>